package com.study.concurrent.A_ThreadManagement.e_ThreadSleepAndRecovery;

import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * Created by 赵超 on 2017/3/18.
 * 每个一秒钟输出一次时间
 */
public class FileClock implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.printf("%s\nstatus : %s %s\n", new Date(),
                    Thread.currentThread().getName(), Thread.currentThread().getState());
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                System.out.printf("The FileClock has been interrupted\nstatus : %s\n",
                        Thread.currentThread().getState());
            }
        }
    }
}
